package com.example.demo.mapper;

import com.example.demo.main.Goods;
import com.example.demo.main.GoodsExample;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface GoodsMapper {
    long countByExample(GoodsExample example);

    int deleteByExample(GoodsExample example);

    int deleteByPrimaryKey(Long goodsId);

    int insert(Goods record);

    int insertSelective(Goods record);

    List<Goods> selectByExample(GoodsExample example);

    Goods selectByPrimaryKey(Long goodsId);

    int updateByExampleSelective(@Param("record") Goods record, @Param("example") GoodsExample example);

    int updateByExample(@Param("record") Goods record, @Param("example") GoodsExample example);

    int updateByPrimaryKeySelective(Goods record);

    int updateByPrimaryKey(Goods record);

    List<Goods> selectLimit(@Param("index")Integer index, @Param("offset")Integer offset);

    int selectCount();

    List<Goods> selectLikeByGoodsName(String str);

    int selectCountOfKind(String kind);

    int selectCountOfGoodsNameLike(String LikeGoodsName);
//    (String kind, Integer Index, Integer offset)

    List<Goods> selectByKindAndLimit(@Param("kind")String kind, @Param("index")Integer index, @Param("offset")Integer offset);

    List<Goods> selectByLikeGoodsNameAndLimit(@Param("str")String str, @Param("index")Integer index, @Param("offset")Integer offset);

//    @Insert("insert into table2 (name) values(#{name})")
    @Update("UPDATE goods SET count=count-1 WHERE goods_name=#{name}")
    int subCount(String name);
}